<template>
  <div>
    <el-form :inline="true" :model="formInline" class="demo-form-inline">
      <el-form-item label="">
        <el-input
          v-model="formInline.CopyNo"
          placeholder="跟单编号"
          clearable
        />
      </el-form-item>
      <el-form-item label="">
        <el-input
          v-model="formInline.PurchaseReturnOrderNo"
          placeholder="单据编码"
          clearable
        />
      </el-form-item>
      <el-form-item label="">
        <el-input
          v-model="formInline.MaterialNo"
          placeholder="物料编码"
          clearable
        />
      </el-form-item>
      <el-form-item label="">
        <el-input
          v-model="formInline.MaterialName"
          placeholder="物料名称"
          clearable
        />
      </el-form-item>

      <el-form-item label="">
        <el-date-picker
          v-model="formInline.StartDocumentDate"
          type="date"
          placeholder="开始日期"
          clearable
        />
      </el-form-item>
      <el-form-item label="">
        <el-date-picker
          v-model="formInline.EndDocumentDate"
          type="date"
          placeholder="结束日期"
          clearable
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="queryPurchaseReturnOrder">查询</el-button>
      </el-form-item>
    </el-form>
  </div>
  <div>
    <el-button type="primary" @click="">单据</el-button>
    <el-button type="primary" @click="">查询所有</el-button>
    <el-button type="primary" @click="router.push('/PurchaseReturnOrders/PurchaseReturnOrderAddView')">新增</el-button>
  </div>
  <div>
    <el-table :data="purchaseReturnOrderData" style="width: 100%">
    <el-table-column prop="purchaseReturnOrderId" label="序号"  />
    <el-table-column prop="copyNo" label="跟单编号"  />
    <el-table-column prop="purchaseReturnOrderNo" label="单据编号" >
      <template #default="scope">
        <el-button type="primary" link @click="router.push('/PurchaseReturnOrders/PurchaseReturnOrderDetailView?purchaseReturnOrderNo='+scope.row.purchaseReturnOrderNo)">{{ scope.row.purchaseReturnOrderNo }}</el-button>
      </template>
    </el-table-column>
    <el-table-column prop="documentsStatus" label="单据状态"  >
      <template #default="scope">
        <span style="color:greenyellow;" v-if="scope.row.documentsStatus==1">审核</span>
      </template>
    </el-table-column>
    <el-table-column prop="supplier" label="供应商"  />
    <el-table-column prop="materialName" label="物料名称" />
    <el-table-column prop="materialNo" label="物料编码"  />
    <!-- <el-table-column prop="" label="退货数量"  />
    <el-table-column prop="" label="出库数量" />
    <el-table-column prop="" label="补收数量"  /> -->
    <el-table-column prop="documentDate" label="单据日期"  >
      <template #default="scope">
        {{ scope.row.documentDate == null? "" : scope.row.documentDate.substring(0, 10) }}
      </template>
    </el-table-column>
  </el-table>
  </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref,reactive,onMounted } from 'vue';
import { useRouter,useRoute } from 'vue-router';
const router = useRouter();
const route = useRoute();
const apiurls = import.meta.env.VITE_APP_API_URL_BasicInformationCommon;//5176
const bpiurls = import.meta.env.VITE_APP_API_URL_BasicInformationWrite;//5013
const cpiurls = import.meta.env.VITE_APP_API_URL_RBACCommon;//5214
const dpiurls = import.meta.env.VITE_APP_API_URL_RBACWrite;//5268
const epiurls = import.meta.env.VITE_APP_API_URL_SalesManagementCommon;//5227
const fpiurls = import.meta.env.VITE_APP_API_URL_SalesManagementWrite;//5020
//钩子
onMounted(()=>{
  queryPurchaseReturnOrder();
})
//查询参数
const formInline = reactive({
  CopyNo: '',
  PurchaseReturnOrderNo: '',
  MaterialNo: '',
  MaterialName: '',
  StartDocumentDate: '',
  EndDocumentDate: '',
  PageIndex:1,
  PageSize:10,
});
//查询数据
const purchaseReturnOrderData:any=ref([]);
//查询方法
const queryPurchaseReturnOrder = ()=>{
  axios.get(epiurls+'/api/SalesOrder/PurchaseReturnOrderQuery',{
    params:{
      CopyNo:formInline.CopyNo,
      PurchaseReturnOrderNo:formInline.PurchaseReturnOrderNo,
      MaterialNo:formInline.MaterialNo,
      MaterialName:formInline.MaterialName,
      StartDocumentDate:formInline.StartDocumentDate,
      EndDocumentDate:formInline.EndDocumentDate,
      PageIndex:formInline.PageIndex,
      PageSize:formInline.PageSize,
    }
  }).then(res=>{
    console.log(res.data);
    purchaseReturnOrderData.value = res.data.data.list;
    
  }).catch(err=>{
    console.log(err);
  })
}

</script>

<style scoped></style>
